package com.kl.forum.service;

import com.kl.forum.dao.CircleCollectMapper;
import com.kl.forum.entity.CircleCollect;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;

@Service
public class CircleCollectService {
    @Autowired
    private CircleCollectMapper circleCollectMapper;

    public int insert(Integer articleId,Integer userId){
        CircleCollect circleCollect=new CircleCollect();
        circleCollect.setCreateTime(new Date());
        circleCollect.setUserId(userId);
        circleCollect.setArticleId(articleId);
        circleCollect.setStatus(1);
         return  circleCollectMapper.insert(circleCollect);
    }

    public CircleCollect findOneCircleCollect(Integer articleId,Integer userId){
        Map map=new HashMap();
        map.put("articleId",articleId);
        map.put("userId",userId);
        return circleCollectMapper.findOneCircleCollect(map);

    }


    public int update(CircleCollect circleCollect){
        return  circleCollectMapper.updateByPrimaryKeySelective(circleCollect);
    }
}
